package com.flower.service.impl;


import com.flower.mapper.FosterMapper;
import com.flower.model.entity.Foster;
import com.flower.service.IFosterService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lm
 * @create 2022-04-17 17:39
 */
@Service
public class ForsterServiceImpl implements IFosterService {

    @Autowired
    private FosterMapper fosterMapper;

    @Override
    public Page<Foster> findPage(Page<Foster> page, String phone, String fosName, String startTime, String fosOper,
                                 String fosStatus) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        return fosterMapper.findPage(page, phone, fosName, startTime, fosOper, fosStatus);

    }

    @Override
    public void saveOrUpdate(Foster foster) {
        if (foster.getId() == null) {
            fosterMapper.add(foster);
        } else {
            fosterMapper.update(foster);
        }
    }

    @Override
    public List<Foster> list() {
        return fosterMapper.list();
    }

    @Override
    public void removeById(Integer id) {
        fosterMapper.removeById(id);
    }

    @Override
    public void removeByIds(List<Integer> ids) {
        ids.forEach(id -> fosterMapper.removeById(id));
    }
}
